from utils.base import VCFBase, CSVBase


class Dbvar(CSVBase):
    """
    Dbvar数据库
    """
    base_path = r"C:\Users\yang\Desktop\fsdownload\dbvar"
    create_syntax = """
        CREATE TABLE `{}` (
          `id` bigint(20) NOT NULL AUTO_INCREMENT,
          `Study ID` varchar(255) DEFAULT NULL,
          `Variant ID` varchar(255) DEFAULT NULL,
          `Variant Region type` varchar(255) DEFAULT NULL,
          `Variant Call type` varchar(255) DEFAULT NULL,
          `Sampleset ID` varchar(255) DEFAULT NULL,
          `Method` varchar(255) DEFAULT NULL,
          `Analysis ID` varchar(255) DEFAULT NULL,
          `Validation` varchar(255) DEFAULT NULL,
          `Variant Samples` varchar(255) DEFAULT NULL,
          `Subject Phenotype` text,
          `Clinical Interpretation` varchar(255) DEFAULT NULL,
          `Assembly Name` varchar(255) DEFAULT NULL,
          `Chromosome Accession` varchar(255) DEFAULT NULL,
          `Chromosome` varchar(255) DEFAULT NULL,
          `Outer Start` varchar(255) DEFAULT NULL,
          `Start` varchar(255) DEFAULT NULL,
          `Inner Start` varchar(255) DEFAULT NULL,
          `Inner End` varchar(255) DEFAULT NULL,
          `End` varchar(255) DEFAULT NULL,
          `Outer End` varchar(255) DEFAULT NULL,
          `Placement Type` varchar(255) DEFAULT NULL,
          `Remap Score` varchar(255) DEFAULT NULL,
          PRIMARY KEY (`id`)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
        """


class VariomeGME(CSVBase):
    """
    VariomeGME数据库
    """
    base_path = r"C:\Users\yang\Desktop\fsdownload\V‎ariomeGME"
    file_suffix = '.tsv'
    file_sep = '\t'
    create_syntax = """
        CREATE TABLE `{}` (
          `id` bigint(20) NOT NULL AUTO_INCREMENT,
          `chrom` varchar(255) DEFAULT NULL,
          `pos` varchar(255) DEFAULT NULL,
          `ref` varchar(255) DEFAULT NULL,
          `alt` varchar(255) DEFAULT NULL,
          `AA` varchar(255) DEFAULT NULL,
          `filter` varchar(255) DEFAULT NULL,
          `FunctionGVS` varchar(255) DEFAULT NULL,
          `geneFunction` varchar(255) DEFAULT NULL,
          `Gene` varchar(255) DEFAULT NULL,
          `GeneID` varchar(255) DEFAULT NULL,
          `SIFT_pred` varchar(255) DEFAULT NULL,
          `GERP++` varchar(255) DEFAULT NULL,
          `AF` varchar(255) DEFAULT NULL,
          `GME_GC` varchar(255) DEFAULT NULL,
          `GME_AC` varchar(255) DEFAULT NULL,
          `GME_AF` varchar(255) DEFAULT NULL,
          `NWA` varchar(255) DEFAULT NULL,
          `NEA` varchar(255) DEFAULT NULL,
          `AP` varchar(255) DEFAULT NULL,
          `Israel` varchar(255) DEFAULT NULL,
          `SD` varchar(255) DEFAULT NULL,
          `TP` varchar(255) DEFAULT NULL,
          `CA` varchar(255) DEFAULT NULL,
          `FunctionGVS_new` varchar(255) DEFAULT NULL,
          `Priority` varchar(255) DEFAULT NULL,
          `Polyphen2_HVAR_pred` varchar(255) DEFAULT NULL,
          `LRT_pred` varchar(255) DEFAULT NULL,
          `MutationTaster_pred` varchar(255) DEFAULT NULL,
          `rsid` varchar(255) DEFAULT NULL,
          `OMIM_MIM` varchar(255) DEFAULT NULL,
          `OMIM_Disease` text,
          `AA_AC` varchar(255) DEFAULT NULL,
          `EA_AC` varchar(255) DEFAULT NULL,
          `rsid_link` varchar(255) DEFAULT NULL,
          `position_link` varchar(255) DEFAULT NULL,
          PRIMARY KEY (`id`)
        ) ENGINE=InnoDB CHARSET=utf8;
        """


class EspLiftover(VCFBase):
    base_path = r"C:\Users\yang\Desktop\fsdownload\liftover"
    id_field = "esp_id"


class Clinvar(VCFBase):
    base_path = r"C:\Users\yang\Desktop\fsdownload\clinvar"
    id_field = 'clinvar_id'


class Jpn(VCFBase):
    base_path = r"E:\4.7jpn"
    id_field = 'jpn_id'


class Exac(VCFBase):
    base_path = r"C:\Users\yang\Desktop\fsdownload\exac"
    id_field = 'exac_id'


class GenomeaSIA(VCFBase):
    base_path = r"C:\Users\yang\Desktop\fsdownload\GenomeaSIA(Asian)"
    id_field = 'genomea_id'


if __name__ == '__main__':
    pass
    # test=Clinvar()
    # test.run()
    from tqdm import tqdm
    import time
    import vcf

    reader = vcf.VCFReader(filename=r"C:\Users\yang\Desktop\fsdownload\1.substitutions.annot.cont_withmaf.vcf.gz")

    result=reader.fetch('22')

    for i in enumerate(tqdm(result)):
        time.sleep(0.2)



